﻿@{
    ViewBag.Title = "网站管理平台_新建推荐产品";
}

@(Html.X().Viewport()
    .Layout("fit")
    .Items(
        Html.X().FormPanel()
            .ID("FormPanel1")
            .Layout("fit")
            .Items(
                Html.X().Panel()
                    .Border(false)
                    .Padding(5)
                    .Layout("form")
                    .Defaults(
                        Html.X().Parameter().Name("AnchorHorizontal").Value("90%")
                    )
                    .Items(
                        Html.X().ComboBox().ID("ProdCataID").FieldLabel("产品目录").Editable(false)
                            .Store(Html.X().Store()
                                .Model(Html.X().Model().IDProperty("ProdCataID")
                                    .Fields(
                                        new ModelField("ProdCataID", ModelFieldType.Int),
                                        new ModelField("ProdCataName")
                                    )
                                )
                                .Proxy(Html.X().AjaxProxy().Url(Url.Action("GetAllProductCata", "ProductCata")).Reader(Html.X().JsonReader().Root("data")))
                            )
                            .DisplayField("ProdCataName")
                            .ValueField("ProdCataID")
                            .Listeners(ls=>ls.Select.Handler="App.ProductID.clearValue(); App.ProductID.getStore().load()"),
                        Html.X().ComboBox().ID("ProductID").FieldLabel("推荐产品").Editable(false)
                            .Store(Html.X().Store()
                                .Model(Html.X().Model().IDProperty("ProductID")
                                    .Fields(
                                        new ModelField("ProductID", ModelFieldType.Int),
                                        new ModelField("ProductName")
                                    )
                                )
                                .Proxy(Html.X().AjaxProxy().Url(Url.Action("GetAllProductByPage", "Product")).Reader(Html.X().JsonReader().Root("data")))
                                .Parameters(p => p.Add(new StoreParameter("cataId", "App.ProdCataID.getValue()", ParameterMode.Raw)))
                            )
                            .DisplayField("ProductName")
                            .ValueField("ProductID"),
                        Html.X().FileUploadField().ID("IndexCover").FieldLabel("上传推荐产品封面").Icon(Icon.ImageAdd).ButtonText(""),
                        Html.X().Label().Text("推荐产品封面的尺寸为130×130，请不要超出这个范围。"),
                        Html.X().NumberField().ID("SortNum").FieldLabel("序号")
                        //Html.X().ComboBox().ID("IndexArea").FieldLabel("显示区域").Editable(false)
                        //    .Items(
                        //        Html.X().ListItem().Text("首页产品1").Value("indexarea1"),
                        //        Html.X().ListItem().Text("首页产品2").Value("indexarea2")
                        //    )
                    )
            )
            .TopBar(
                Html.X().Toolbar().Items(
                    Html.X().Button().Text("保存").Icon(Icon.Disk)
                        .DirectEvents(de =>
                        {
                            de.Click.Action = "CreateRecomProduct";
                            de.Click.EventMask.ShowMask = true;
                            de.Click.EventMask.Msg = "正在保存";
                            de.Click.Success = "ext.net.comjs.onSubmitSuccess";
                            de.Click.Failure = "ext.net.comjs.onSubmitFailure";
                            de.Click.IsUpload = true;
                        })
                        .Listeners(ls =>
                        {
                            ls.Click.Handler = "return ext.net.comjs.onFormSubmit()";
                        })
                )
            )
            .BottomBar(Html.X().StatusBar().DefaultText("Ready"))
                .Listeners(ls => ls.ValidityChange.Handler = "ext.net.comjs.setFormStatusBar(this, valid)")
    )
)